<template>
	<view class="container">
		<uni-list v-for="(item,index) in bookList" :key="index">
			<uni-list-item :title="item.name" :note="item.phone" :rightText="item.createTime" showArrow></uni-list-item>
		</uni-list>
		<button type="primary" class="btn-fixed-bottom" @tap="toPerBook">个人预约申请</button>
	</view>
</template>

<script>
import { bookRecord } from '@/api/book.js'
// import { reactive, ref } from 'vue'
import { formateDate } from '@/utils/formatDate.js'
// import { getLocationParams } from '@/utils/locationParams.js'
export default{
	onLoad(option) {
		console.log(1111, option);
		let idNumber = option.idNumber
		this.getBookList(idNumber)
	},
	data(){
		return{
			bookList:[]
		}
	},
	methods:{
		// 获取预约列表
		async getBookList(idNumber) {
			const {data} = await bookRecord(idNumber)
			if(data){
				data.map(item => {
					item.createTime = formateDate(new Date(item.createTime), 'yyyy-MM-dd')
				})
			}
			this.bookList = data
		},
		// 去个人预约页
		 toPerBook () {
			uni.navigateTo({
				url: '/pages/personBook/perBook',
			});
		}
	}
	// setup() {
	// 	// 获取预约列表
	// 	let bookList = ref([])
	// 	const getBookList = async (idNumber) => {
	// 		const {data} = await bookRecord(idNumber)
	// 		bookList.value = data
	// 	}
	// 	console.log(2222, idNumber);
	// 	if(idNumber) getBookList(idNumber)
		
		
	// 	// 去个人预约页
	// 	const toPerBook = () => {
	// 		uni.navigateTo({
	// 			url: '/pages/personBook/perBook',
	// 		});
	// 	}
	// 	return{
	// 		toPerBook,
	// 		getBookList,
	// 		bookList,
	// 		formateDate
	// 	}
	// }
}
</script>

<style>
</style>
